package liu.de.service;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author liude
 */
@Service
public class UserService {

    private AtomicInteger identity = new AtomicInteger(0);

//    @Cacheable(cacheNames = "user")

    /**
     * 测试缓存
     *
     * @param name name
     * @return User
     */
    public User getUser(String name) {
        return User.builder()
                .id(identity.incrementAndGet())
                .name(name)
                .createDateTime(LocalDateTime.now())
                .build();
    }

    @SuppressWarnings("WeakerAccess")
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class User implements Serializable {
        Integer id;
        String name;
        LocalDateTime createDateTime;
    }
}
